// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_pr.p_c;

import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;
import android.text.TextUtils;
import com.nnee.p_pr.p_atom.cls_u;
import com.nnee.p_pr.p_prot.cls_a;
import com.nnee.p_pr.p_prot.cls_h;
import com.nnee.p_pr.p_prov.p;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

// Referenced classes of package com.nnee.p_pr.c:
//            g

public class cls_e
{

    public cls_e()
    {
    }

    private static LinkedList a(Context context, String s, String s1, boolean flag)
    {
        if(context == null) goto _L2; else goto _L1
_L1:
        Cursor cursor;
        ContentResolver contentresolver = context.getContentResolver();
        android.net.Uri uri = p.j;
        String as[] = a;
        String as1[] = new String[1];
        as1[0] = s;
        cursor = contentresolver.query(uri, as, "account =?", as1, "timestamp DESC");
        if(cursor == null) goto _L2; else goto _L3
_L3:
        if(!cursor.moveToFirst()) goto _L5; else goto _L4
_L4:
        LinkedList linkedlist;
        linkedlist = new LinkedList();
        do
            if(flag)
            {
                String s2 = cursor.getString(6);
                if(!TextUtils.isEmpty(s2))
                    try
                    {
                        (new cls_h(new cls_a(new cls_g(linkedlist)))).a(com.nnee.p_pr.p_a.cls_e.a(s2));
                    }
                    catch(Exception exception)
                    {
                        exception.printStackTrace();
                    }
            } else
            {
                cls_u u1 = new cls_u();
                u1.q(cursor.getString(2));
                u1.r(cursor.getString(7));
                linkedlist.add(u1);
            }
        while(cursor.moveToNext());
        cursor.close();
_L7:
        return linkedlist;
_L5:
        cursor.close();
_L2:
        linkedlist = null;
        if(true) goto _L7; else goto _L6
_L6:
    }

    public static LinkedList a(Context context, String s, boolean flag)
    {
        return a(context, s, null, flag);
    }

    public static void a(Context context, String s, cls_u u1)
    {
        if(context != null && !TextUtils.isEmpty(s) && u1 != null)
        {
            ContentValues contentvalues = new ContentValues();
            contentvalues.put("account", s);
            contentvalues.put("uid", u1.V());
            contentvalues.put("updated", u1.Y());
            contentvalues.put("timestamp", Long.valueOf(System.currentTimeMillis()));
            contentvalues.put("title", u1.U());
            contentvalues.put("type", "f");
            contentvalues.put("file", u1.toString());
            context.getContentResolver().insert(p.j, contentvalues);
        }
    }

    public static void a(Context context, String s, LinkedList linkedlist)
    {
        if(linkedlist != null && linkedlist.size() > 0)
        {
            LinkedList linkedlist1 = new LinkedList();
            Iterator iterator = linkedlist.iterator();
            do
            {
                if(!iterator.hasNext())
                    break;
                cls_u u1 = (cls_u)iterator.next();
                if(u1 != null)
                    linkedlist1.add(u1.V());
            } while(true);
            a(context, s, ((List) (linkedlist1)));
        }
    }

    public static void a(Context context, String s, List list)
    {
        if(context != null && list != null && list.size() != 0)
        {
            StringBuilder stringbuilder = new StringBuilder();
            stringbuilder.append("account").append(" = '").append(s).append("' AND ").append("uid").append(" in (");
            String s1;
            for(Iterator iterator = list.iterator(); iterator.hasNext(); stringbuilder.append('\'').append(s1).append('\'').append(','))
                s1 = (String)iterator.next();

            stringbuilder.deleteCharAt(-1 + stringbuilder.length());
            stringbuilder.append(')');
            context.getContentResolver().delete(p.j, stringbuilder.toString(), null);
        }
    }

    private static void a(SQLiteStatement sqlitestatement, int l, String s)
    {
        if(s == null)
            sqlitestatement.bindNull(l);
        else
            sqlitestatement.bindString(l, s);
    }

    public static boolean a(Context context, String s, String s1)
    {
        boolean flag = true;
        if(context != null)
        {
            ContentResolver contentresolver = context.getContentResolver();
            android.net.Uri uri = p.j;
            String as[] = new String[2];
            as[0] = s;
            as[flag] = s1;
            if(contentresolver.delete(uri, "account =?  AND uid =?", as) <= 0)
                flag = false;
        } else
        {
            flag = false;
        }
        return flag;
    }

    public static boolean b(Context context, String s, String s1)
    {
        return a(context, s, s1);
    }

    public static boolean c(Context context, String s, String s1)
    {
        boolean flag;
        if(context == null || TextUtils.isEmpty(s) || TextUtils.isEmpty(s1))
        {
            flag = false;
        } else
        {
            String s2 = (new StringBuilder()).append("account = '").append(s).append("' AND ").append("uid").append(" = '").append(s1).append("'").toString();
            Cursor cursor = context.getContentResolver().query(p.j, a, s2, null, null);
            if(cursor != null)
            {
                if(cursor.moveToFirst())
                    flag = true;
                else
                    flag = false;
                cursor.close();
            } else
            {
                flag = false;
            }
        }
        return flag;
    }

    static String a[];
    public static final int b = 0;
    public static final int c = 1;
    public static final int d = 2;
    public static final int e = 3;
    public static final int f = 4;
    public static final int g = 5;
    public static final int h = 6;
    public static final int i = 7;
    public static final int j = 8;
    private static final String k = "f";

    static 
    {
        String as[] = new String[9];
        as[0] = "_id";
        as[1] = "account";
        as[2] = "uid";
        as[3] = "updated";
        as[4] = "timestamp";
        as[5] = "other";
        as[6] = "file";
        as[7] = "title";
        as[8] = "type";
        a = as;
    }
}
